package com.UnionPayCenter.account.enums;

import com.UnionPayCenter.enums.CodeBaseEnum;
import com.UnionPayCenter.exception.ApiException;

public enum PayStatusEnum implements CodeBaseEnum {

    TO_PAY(0, "待支付"),
    NOT_PAY(1, "未支付"),
    PAYING(2, "支付中"),
    SUCCESS(3, "支付成功"),
    FAIL(4, "支付失败");

    private int code;

    private String msg;

    PayStatusEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static PayStatusEnum getEnum(int code) {
        for (PayStatusEnum ele : PayStatusEnum.values()) {
            if (ele.code == code) {
                return ele;
            }
        }
        throw new ApiException(404, "不正确的支付状态码");
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }
}
